package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.dtos.WmChannelListDto;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ybw
 * @version 1.0
 * @date 2021/12/13 20:19
 */
@RestController
@RequestMapping("/api/v1/channel/")
public class ChannelController {
  @Autowired
  private WmChannelService wmChannelService;

  /**
   * 频道列表
   * @return
   */
  @GetMapping("/channels")
  public ResponseResult findAll(){
    return wmChannelService.findAll();
  }

  /**
   * 保存频道
   * @param dto
   * @return
   */
  @PostMapping("/save")
  public ResponseResult saveChannel(@RequestBody WmChannelDto dto){
    return wmChannelService.saveChannel(dto);
  }

  /**
   * 分页模糊查询频道列表
   * @param dto
   * @return
   */
  @PostMapping("/list")
  public ResponseResult channelList(@RequestBody WmChannelListDto dto){
    return wmChannelService.channelList(dto);
  }

  /**
   * 修改频道信息
   * @param dto
   * @return
   */
  @PostMapping("/update")
  public ResponseResult updateChannel(@RequestBody WmChannelDto dto){
    return wmChannelService.updateChannel(dto);
  }

  /**
   * 删除频道
   * @param id
   * @return
   */
  @GetMapping("/del/{id}")
  public ResponseResult delChannel(@PathVariable Integer id){
    return wmChannelService.delChannel(id);
  }
}
